package com.jcnet.bizaia.adapter;

import java.util.List;

import com.androidquery.AQuery;
import com.androidquery.callback.ImageOptions;
import com.jcnet.bizaia.App;
import com.jcnet.bizaia.R;
import com.jcnet.bizaia.bean.MainInfoBean;
import com.jcnet.bizaia.bean.VodDetailTalkBean;
import com.squareup.picasso.Picasso;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

public class VodTalkAdapter extends BaseAdapter {

	private Context context;
	private List<VodDetailTalkBean> infoBeans;
	public int count;
	private ImageOptions options;
	
	
	
	
	public VodTalkAdapter(Context context, List<VodDetailTalkBean> infoBeans) {
		super();
		this.context = context;
		this.infoBeans = infoBeans;
	}

	@Override
	public int getCount() {
		// TODO Auto-generated method stub
		count = infoBeans.size();
		return count;
	}

	@Override
	public Object getItem(int position) {
		// TODO Auto-generated method stub
		return position;
	}

	@Override
	public long getItemId(int position) {
		// TODO Auto-generated method stub
		return position;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		// TODO Auto-generated method stub
		ViewHolder holder;
        if(convertView == null)
        {
            holder = new ViewHolder();
            convertView = View.inflate(context,R.layout.vod_talk_lay, null);
            holder.imageView = (ImageView)convertView.findViewById(R.id.imageView) ;
            holder.titleTextView = (TextView)convertView.findViewById(R.id.title);
            holder.subTitleTextView = (TextView)convertView.findViewById(R.id.subTitle);
            holder.timeTextView = (TextView)convertView.findViewById(R.id.time);
            
            convertView.setTag(holder);
        }else
        {
            holder = (ViewHolder)convertView.getTag();
            
        }
        
        VodDetailTalkBean infoBean  =  infoBeans.get(position);
        if(infoBean!=null){
        	
        	holder.titleTextView.setText(infoBean.getNickname());
        	holder.subTitleTextView.setText(infoBean.getContent());
        	holder.timeTextView.setText(infoBean.getDateline());
           // aQuery.id(holder.imageView).image(App.HTTP_PATH+infoBean.getPictureurl(), options);
        	Picasso.with(context)
        	  .load(App.HTTP_PATH+infoBean.getComimage())
        	  .resize(80, 60)
        	  .centerCrop()
        	  .into(holder.imageView);
        }
		return convertView;
	}

	static class ViewHolder{
		ImageView imageView;
		TextView subTitleTextView;
		TextView titleTextView;
		TextView timeTextView;
	}
}
